#include "lua_c_api/include/lua.hpp"
#include "reaper_plugin/reaper_plugin.h"

void pushLud(lua_State *L, void *ptr);
void *checkLud(lua_State *L, int ludidx);

// our typed accessors:
// (reaper.void is a pointer to void, *not* a void itself (it ain't nuthin'))

#define REAPER_void						"reaper.void"
#define REAPER_MediaTrack				"reaper.MediaTrack"
#define REAPER_MediaItem				"reaper.MediaItem"
#define REAPER_MediaItem_Take			"reaper.MediaItem_Take"
#define REAPER_MIDI_event_t				"reaper.MIDI_event_t"
#define REAPER_PCM_source_transfer_t	"reaper.PCM_source_transfer_t"

#define REAPER_PCM_source_peaktransfer_t		"reaper.PCM_source_peaktransfer_t"
#define REAPER_midi_realtime_write_struct_t		"reaper.midi_realtime_write_struct_t"
#define REAPER_midi_quantize_mode_t				"reaper.midi_quantize_mode_t"

#define decltopush(TS)									\
	TS * to##TS (lua_State *L, int idx);				\
	int push##TS (lua_State *L, TS *p );

decltopush(void);
decltopush(MediaTrack);
decltopush(MediaItem);
decltopush(MediaItem_Take);
decltopush(MIDI_event_t);

decltopush(PCM_source_transfer_t);
decltopush(PCM_source_peaktransfer_t);
decltopush(midi_realtime_write_struct_t);
decltopush(midi_quantize_mode_t);

void reaperMetatables(lua_State *L);